PR for company registration form for admin user#213
Open
Naman-56-56 wants to merge 2 commits intoSpoken-tutorial:react-tsfrom
Open
PR for company registration form for admin user#213Naman-56-56 wants to merge 2 commits intoSpoken-tutorial:react-tsfrom
Naman-56-56 wants to merge 2 commits intoSpoken-tutorial:react-tsfrom
Conversation
Naman-56-56
commented
Oct 23, 2025
- Added company addition form for admin at the 'http://127.0.0.1:5173/admin/companies/add' endpoint
- Used RHF wrappers for consistency
- Implemented the form similarly to the form at 'http://127.0.0.1:5173/register/company' endpoint for consistency
- Added necessary url endpoints to router
ankitamk14
requested changes
Oct 24, 2025
| <Typography variant="h4">Add New Company</Typography> | ||
|
|
||
| <FormProvider {...methods}> | ||
| <Paper sx={{ p: 3 }}> |
Collaborator
There was a problem hiding this comment.
- Wrap fields in a
<form>and submit properly
(handleSubmit on a button onClick skips native form submit) - add noValidate -- as we are validating via zod -- may give inconsistency
Suggested change
| <Paper sx={{ p: 3 }}> | |
| <Paper sx={{ p: 3 }} component="form" noValidate onSubmit={methods.handleSubmit(onSubmit)}> |
Comment on lines
86
to
92
| <Button | ||
| variant="contained" | ||
| onClick={methods.handleSubmit(onSubmit)} | ||
| disabled={addCompany.isPending} | ||
| > | ||
| {addCompany.isPending ? 'Adding...' : 'Add Company'} | ||
| </Button> |
Collaborator
There was a problem hiding this comment.
Suggested change
| <Button | |
| variant="contained" | |
| onClick={methods.handleSubmit(onSubmit)} | |
| disabled={addCompany.isPending} | |
| > | |
| {addCompany.isPending ? 'Adding...' : 'Add Company'} | |
| </Button> | |
| <Button type="submit" variant="contained" disabled={loadingMeta || addCompany.isPending || methods.formState.isSubmitting}> |
Comment on lines
42
to
49
| export const adminCompanySchema = z.object({ | ||
| name: z.string().min(2, 'Required'), | ||
| website: z.url('Invalid URL').optional().or(z.literal('')), | ||
| domain: z.string().min(1, 'Required'), | ||
| state: z.string().min(1, 'Required'), | ||
| city: z.string().min(2, 'Required'), | ||
| address: z.string().min(5, 'Required'), | ||
| }) |
Collaborator
There was a problem hiding this comment.
Improve Zod messages and empty-string handling for URL
Suggested change
| export const adminCompanySchema = z.object({ | |
| name: z.string().min(2, 'Required'), | |
| website: z.url('Invalid URL').optional().or(z.literal('')), | |
| domain: z.string().min(1, 'Required'), | |
| state: z.string().min(1, 'Required'), | |
| city: z.string().min(2, 'Required'), | |
| address: z.string().min(5, 'Required'), | |
| }) | |
| const emptyToUndefined = <T extends z.ZodTypeAny>(schema: T) => | |
| z.preprocess((v) => (v === '' ? undefined : v), schema) | |
| export const adminCompanySchema = z.object({ | |
| name: z.string().min(5, 'Must be at least 5 characters'), | |
| website: emptyToUndefined(z.string().url('Invalid URL')).optional(), | |
| domain: z.string().min(1, 'Required'), | |
| state: z.string().min(1, 'Required'), | |
| city: z.string().min(2, 'Must be at least 2 characters'), | |
| address: z.string().min(5, 'Must be at least 5 characters'), | |
| }) | |
| <FormProvider {...methods}> | ||
| <Paper sx={{ p: 3 }}> | ||
| {loadingMeta ? ( | ||
| <Typography>Loading options…</Typography> |
Collaborator
There was a problem hiding this comment.
ux polish : Add a Skeleton instead of plain “Loading options…”.
https://mui.com/material-ui/react-skeleton/
| }: { domains: string[]; states: { code: string; name: string }[] }) { | ||
| return ( | ||
| <Stack spacing={2}> | ||
| <RHFTextField name="name" label="Company Name" fullWidth /> |
Collaborator
There was a problem hiding this comment.
ux polish :
Autofocus first field
Suggested change
| <RHFTextField name="name" label="Company Name" fullWidth /> | |
| <RHFTextField name="name" label="Company Name" fullWidth autoFocus /> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.